module("kong.plugins.rbactest.common", package.seeall)

function debug_info(...)
    for k, v in pairs({...}) do
        if type(v) == "table" then
            for k1, v1 in pairs(v) do
                if type(v1) == "table" then
                    for k2, v2 in pairs(v1) do
                        kong.log.debug("key[<" .. k1 .. ">]==>" .. "table[[<" ..
                                           k2 .. ">:::" .. "type[" .. type(v2) ..
                                           "]===>" .. "(" .. tostring(v2) ..
                                           ")]]")
                    end
                else
                    kong.log.debug(
                        "key[<" .. k .. ">]==>" .. "table[[<" .. k1 .. ">:::" ..
                            "type[" .. type(v1) .. "]===>" .. "(" ..
                            tostring(v1) .. ")]]")
                end
              end
        end
        if type(v) ~= "table" then
                    kong.log.debug("key[<" .. k .. ">]:::==>" .. "type[" ..
                                       type(v) .. "]===>" .. "(" .. tostring(v) ..
                                       ")==")
        end
    end
end

function split(szFullString, szSeparator)
    local nFindStartIndex = 1
    local nSplitIndex = 1
    local nSplitArray = {}
    while true do
        local nFindLastIndex = string.find(szFullString, szSeparator,
                                           nFindStartIndex)
        if not nFindLastIndex then
            nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex,
                                                  string.len(szFullString))
            break
        end
        nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex,
                                              nFindLastIndex - 1)
        nFindStartIndex = nFindLastIndex + string.len(szSeparator)
        nSplitIndex = nSplitIndex + 1
    end
    return nSplitArray
end

